Conversation
There was a problem hiding this comment.
Pull request overview
This pull request makes unsafe code opt-in for consumers of the PolyShim package, rather than automatically enabling it. Previously, the package automatically enabled AllowUnsafeBlocks for all consumers, which could have security and compatibility implications.
Key changes:
- Unsafe code is now opt-in: consumers must explicitly set
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>to use polyfills that require unsafe code (e.g., Span with stackalloc) - Conditional compilation is used to only include unsafe polyfill features when the consumer has enabled unsafe blocks
- Comprehensive documentation added explaining when and how to enable unsafe code
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| Readme.md | Added documentation section explaining unsafe code requirements, with examples showing how to enable it and when it's needed. Updated compatibility package example to better demonstrate System.Memory usage. |
| PolyShim/PolyShim.props | Removed automatic AllowUnsafeBlocks setting that was previously forced on all consumers |
| PolyShim/PolyShim.targets | Added conditional compilation constant ALLOW_UNSAFE_BLOCKS when consumer enables unsafe blocks |
| PolyShim/PolyShim.csproj | Added AllowUnsafeBlocks for building the PolyShim package itself |
| PolyShim/NetCore21/Span.cs | Changed unsafe constructor to be conditionally compiled based on ALLOW_UNSAFE_BLOCKS define. Simplified pointer arithmetic implementation from Unsafe.Read to direct pointer indexing. |
| PolyShim.Tests/PolyShim.Tests.csproj | Enabled AllowUnsafeBlocks for test project to test unsafe polyfill features |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #69 +/- ##
============================
============================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.